<?php
$a=['张三丰','里  斯','阿 kit','papi 酱','Jackson'];
outFormat(35,$a);
outFormat(30,$a);
function outFormat(int $width, ?array $a):void {

    if(is_null($a))return;
    foreach ($a as $item){
        $name=str_replace(' ','', $item);
        $right=bin2hex($name);
        $right=strtoupper($right);
        $right=chunk_split($right,2,'_');
        //$right=rtrim($right, '_');
        //$right=substr($right,0, strlen($right)-1);
        $right=substr($right,0, -1);
        $rightLength=strlen($right);
        $nameLength=strlen( iconv('utf-8','GBK',$name) );
        $spaceLength=$width-$nameLength-$rightLength;
        if($spaceLength<0)$spaceLength=0;
        echo $name, str_repeat(' ',$spaceLength),$right,"\n";
    }

}
